﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Task4
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            //此处添加的代码，将在窗体关闭前自动执行
            //弹出自定义对话框
            DialogResult result = MessageBox.Show("确定要关闭本窗体？","提示：",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
            //判断用户选择了那个按钮
            if (result!=DialogResult.Yes)
            {
                e.Cancel = true;
            }
        }
    }
}
